package com.mimiwang.oss.service;

import com.aliyun.oss.model.ObjectListing;

import java.io.File;
import java.io.InputStream;
import java.util.Map;

/**
 * @AUTHOR:游李滨
 * @DATE:2022/10/2 20:21
 */
public interface OssFileService {

    boolean createBucket(String bucketName);


    InputStream downloadFile(String bucketName,String objectName);


    /**
     *
     * 默认bucket+默认dir+uuidName
     *
     * */
    String uploadFile(File file);

    /**
     *
     * 默认bucket+objectName
     *
     * */
    String uploadFile(String objectName, File file);


    /**
     *
     * bucket+默认dir+uuidName
     *
     * */
    String uploadFile(File file, String bucketName);

    /**
     *
     * 全限定方法
     *
     * */
    String uploadFile(File file,String bucketName,String objectName);

    String uploadFile(String fileName,InputStream inputStream);
    /**
     *
     * 默认bucket+objectName
     *
     * */
    String uploadFile(InputStream inputStream,String objectName);

    /**
     *
     * bucket+默认objectName
     *
     * */
    String uploadFile(String bucket, InputStream inputStream, String fileName);


    /**
     *
     * 全限定
     *
     * */
    String uploadFile(InputStream inputStream, String bucketName, String objectName);


//    for (OSSObjectSummary objectSummary : objectListing.getObjectSummaries()) {
//            System.out.println(" - " + objectSummary.getKey() + "  " +
//              "(size = " + objectSummary.getSize() + ")");
//    }
//
    ObjectListing list(String bucketName);

    String getUrl(String bucketName,String endpoint,String objectName);
    String getUrl(String objectName);

    Map<String,String> getSignature();
    Map<String,String> getSignature(String bucketName,String dirName);

}
